Env.aggregate(Object, {
	
	/**
	 * Gets the object from specified path.
	 * Clears the given path array - it will be invalid for later usage.
	 * 
	 * @param Hash o - object to retrieve the value from
	 * @param Array p - array path
	 */
	get: function(o, p) {
		for(var i = 0, l = p.length; o !== undefined && i < l; i++) {
			o = o[p[i]];
		}
		return o;
	},
	
	/**
	 * Sets value under specified path.
	 * 
	 * @param Hash o - object to set the value into
	 * @param Array p - array path
	 * @param Any v - value to set into the object
	 */
	set: function(o, p, v) {
		var	i = 0, l = p.length-1;
		while(l--) {
			var e = p[i++]
			o[e] = o[e] || {};
			o = o[e];
		}
		o[p[i]] = v;
	},

	/**
	 * Merges objects & returns result hash.
	 * Accepts up to three objects. 
	 * If keys overlaps, the later object will override the previous ones.
	 */
	merge: function() {
		var l = arguments.length, r = {};
		
		for(var i = 0; i < l; i++) {
			for(var k in arguments[i]) {
				r[k] = arguments[i][k];
			}
		}
		return r;
	},

	/**
	 * Clones object's properties into another object.
	 * Performs shallow copy.
	 */
	clone: function(o) {
		return Object.merge(o);
	}
});


/**
 * Extending Object.each to handle execution context as a second argument.
 */
Object.yuiEach = Object.each;

Object.each = function(o, c, f) {
	if(typeof c === "function") { Object.yuiEach(o, c, f); }
	else { Object.yuiEach(o, f, c); }
};

Object.keys = window.Object.keys ? window.Object.keys : Object.keys;
Object.create = window.Object.create ? window.Object.create : Object;